A comprehensive e-commerce API that integrates JWT authentication for secure user sessions and Stripe for payment processing. It includes features such as user creation, shopping cart management, product listings, and the ability to create and edit products in the database. The API allows users to add products to a cart, handle payments via Stripe, and manage product inventory dynamically.
- JWT authentication for secure user sessions
- User registration and login
- Shopping cart management
- Integration with Stripe for payment processing
- Product listings and detailed view
- Ability to create new products
- Edit existing products in the database
- Manage product inventory dynamically
- Handle user payments and update cart status
Project idea from: https://roadmap.sh/projects/ecommerce-api
- Clone the project repo
- Navigate into the project directory
- Install the dependencies
- Create your own MongoDB database
- I used mail trap and nodemailer for my email service. you can check them out on npm
- Create your
.env
file - Add the following environment variables
- Run the project
git clone https://github.com/NAJIB-B/simple-E-commerce-API.git
cd simple-E-commerce-API
npm install
(I used MongoDB Atlas)
(So be sure to use those unless you want to edit the project and use something else)
touch .env
Populate the .env
file with the following variables, replacing the placeholders with your own details:
DATABASE="mongodb+srv://<username>:<password>@cluster0.mongodb.net/<database-name>?retryWrites=true&w=majority&appName=Cluster0"
PORT=<port>
JWT_SECRET=<your-access-token-secret>
JWT_EXPIRES_IN=<time-for-expiry>
MAIL_HOST=<your-mail-host>
MAIL_PORT=<your-mail-port>
MAIL_USERNAME=<your-mail-username>
MAIL_PASSWORD=<your-mail-password>
STRIP_API_KEY=<your-stripe-api-key>
STRIPE_WEBHOOK_SECRET=<your-stripe-webhook-secret>
Note:
npm start